home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ETO Development Tools 4
/
ETO Development Tools 4.iso
/
Tools - Objects
/
MacsBug
/
MacsBug 6.2.1
/
dcmds
/
C Samples
/
Echo.c
< prev
next >
Wrap
Text File
|
1991-05-01
|
2KB
|
78 lines
/* Echo.c
The following MPW commands will build the dcmd and copy it to the
"Debugger Prefs" file in the System folder. The dcmd's name in
MacsBug will be the name of the file built by the Linker.
C Echo.c
Link {dcmdLib}dcmdGlue.a.o Echo.c.o {dcmdLib}DRuntime.o {CLibraries}StdCLib.o -o Echo
BuildDcmd Echo 101
Echo 'include "Echo";' | Rez -a -o "{systemFolder}Debugger Prefs"
*/
#include <Types.h>
#include "dcmd.h"
void NumberToHex (long number, Str255 hex)
{
Str255 digits = "0123456789ABCDEF";
int n;
strcpy (hex, &".00000000");
hex[0] = 8;
for (n = 8; n >= 1; n--)
{
hex[n] = digits[number % 16];
number = number / 16;
}
} // NumberToHex
pascal void CommandEntry (dcmdBlock* paramPtr)
{
short pos, ch;
long value;
Boolean ok;
Str255 str;
switch (paramPtr->request)
{
case dcmdInit:
break;
case dcmdHelp:
dcmdDrawLine ("\pECHO [params...]");
dcmdDrawLine ("\p Echo the command line parameters");
break;
case dcmdDoIt:
do {
// Save the position so we can rewind if we get an error
pos = dcmdGetPosition ();
ch = dcmdPeekAtNextChar ();
if (((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z')))
{ // Get the parameter as a text string
ch = dcmdGetNextParameter (str);
dcmdDrawLine (str);
}
else
{ // Get the parameter as a 32 bit value
ch = dcmdGetNextExpression (&value, &ok);
if (ok)
{ // The expression was parsed correctly
NumberToHex (value, str);
dcmdDrawLine (str);
}
else
{ // The expression contained an error. Get it as a string
dcmdSetPosition (pos);
ch = dcmdGetNextParameter (str);
dcmdDrawLine (str);
}
}
} while (ch != '\n');
break;
}
} // CommandEntry